<?php

namespace app\api\model;

use app\common\model\LanguageGrade as LanguageGradeModel;

class LanguageGrade extends LanguageGradeModel
{
    /**
     * 语种等级
     */
    public static function getBySearch($name)
    {
        $tcGrade = TeacherCourse::getGradeId($name);
        $lGrade = self::getIdByLanguage($name);
        $gradeId = array_merge($tcGrade, $lGrade);
        return self::whereIn('language_grade_id', $gradeId)->select();
    }

    public static function getIdByLanguage($name)
    {
        $languageId = Language::getBySearch($name);
        $gradeId =  self::whereIn('language_id', $languageId)->column('language_grade_id');
        return $gradeId ?: [];
    }

}
